import type { App } from 'vue'

import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import SvgIcon from '@/components/SvgIcon/index.vue'
import Paginate from '@/components/Paginate/index.vue'
import Category from '@/components/Category/index.vue'

const components = {
    SvgIcon,
    Paginate,
    Category,
}

// 类型安全的注册函数
const registerGlobalComponents = (app: App) => {
    Object.entries(components).forEach(([name, component]) => {
        app.component(name, component)
    })

    // 注册 Element Plus 图标
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
        app.component(key, component)
    }
}

export default {
    install: registerGlobalComponents,
}
